package cn.shyouchi.wuguanjia.android.ui.patrol;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.impl.ModuleItemClickListener;

/**
 * Created by Eenie on 2016/12/27 at 17:47
 * Email: 472279981@qq.com
 * Des:
 */

public class PatrolModuleAdapter extends BaseQuickAdapter<PatrolModuleEntity,BaseViewHolder> {

    ModuleItemClickListener mItemClickListener;

    public PatrolModuleAdapter(List<PatrolModuleEntity> data, ModuleItemClickListener listener) {

        super(R.layout.item_patrol_module_layout, data);
        this.mItemClickListener = listener;
    }

    @Override
    protected void convert(BaseViewHolder holder, final PatrolModuleEntity entity) {

        holder.setText(R.id.tv_module_name, entity.getName());
        holder.setImageResource(R.id.img_module_ico, entity.getIco_res());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 mItemClickListener.moduleItemClick(entity);
            }
        });
    }
}
